/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ece.fr.edu.fac.controleur.outils;

import java.sql.Date;


/**
 *
 * @author smarzoug
 */
public class DateEncapsulation {
    
    //static String month[]={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"};
    static String month[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
    /** Creates a new instance of DateWrapper */
    public DateEncapsulation() 
    {
        
    }
    
    public static String parseDate(String date)
    {
    	int monthid=Integer.parseInt(date.substring(date.indexOf("-")+1,date.lastIndexOf("-")));
        String newdate=date.substring(0,date.indexOf("-"))+"-"+month[monthid-1]+"-"+(date.substring(date.lastIndexOf("-")+1,date.length()));
        return newdate;
    }     
    public static String parseDate(Date date)
    {
    	String olddate=date.toString();
    	String newdate=olddate.substring(olddate.lastIndexOf("-")+1, olddate.length())+"-"+olddate.substring(olddate.indexOf("-")+1, olddate.lastIndexOf("-"))+"-"+olddate.substring(0,olddate.indexOf("-"));
	return newdate;
    	
    }
}
